<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">  
      
    <h:head>
        <title>Online Library</title>
        
 
              

     <h:outputStylesheet library="css" name="OnlineLibrary-style.css"/>      
        
     
    
    </h:head>
    <h:body>
        
        <div id="header">
        <br/>
            <p id="welcome">Welcome to the Online Library Tool</p>
        <br/>
        </div>
        <br/>
        <h:form>
            <h:outputLabel for="tile" rendered="true" value="Title: "/>
            
            <h:inputText id="title" required="true" 
                         value="#{jSFLibraryManagerBean.title}"/><br/><br/>
            
            <h:outputLabel for="author" rendered="true" value="Author: "/>
            
            <h:inputText id="author" required="true" 
                         value="#{jSFLibraryManagerBean.author}"/><br/><br/>
            
            <h:outputLabel for="publisher" rendered="true" value="Publisher: "/>
            
            <h:inputText id="publisher" required="true" value="#{jSFLibraryManagerBean.publisher}"/><br/><br/>
                               
            <h:outputLabel for="publicationYear" rendered="true" value="Year Published: "/>
            
            <h:inputText id="publicationYear" required="true" 
                         value="#{jSFLibraryManagerBean.publicationYear}"/><br/><br/>
                              
            
            <h:outputLabel for="media" rendered="true" value="Type of Media: "/>
            <br/>   
            <h:selectOneMenu id="media" required="true" 
                             value="#{jSFLibraryManagerBean.format}">
            
            <f:selectItem itemLabel="Book" itemValue="Book"/>
            <f:selectItem itemLabel="Audio" itemValue="Audio"/>
            <f:selectItem itemLabel="Video" itemValue="Video"/>
            </h:selectOneMenu>
            <br/><br/>
            
            <h:outputLabel for="status" rendered="true" value="Status"/>
           <br/>
            <h:selectOneMenu id="status" required="true" value="#{jSFLibraryManagerBean.status}">
            <f:selectItem itemLabel="Available" itemValue="Available"/>
            <f:selectItem itemLabel="Checked-Out" itemValue="Checked-Out"/>
            <f:selectItem itemLabel="Missing" itemValue="Missing"/>
            </h:selectOneMenu>
            
                             
            
           <br/><br/>
            <h:commandButton value="Add Item" action="#{jSFLibraryManagerBean.createLibraryItem()}"/>
            
            
        </h:form>
        <p> Search By title</p>
        <h:form>
            <h:inputText id="searchItem" 
                         
                         value="#{jSFLibraryManagerBean.searchTitle}" 
                         
                         
                         required="true"  />
            <h:commandButton value="Search" 
                             action="#{jSFLibraryManagerBean.findItem}"/>
            
            
            
            
        </h:form> 
        
        <h:outputText value="Item Found" 
                      rendered="#{jSFLibraryManagerBean.toggleResults()}"/>
       
        <h:form/>
        <h:dataTable var="item" value="#{jSFLibraryManagerBean.resultItem}"
                     rendered="#{jSFLibraryManagerBean.toggleResults()}">
        
            <h:column>
                <f:facet name="header">
                    <h:outputText value="ID"/>
                </f:facet>
                <h:outputText value="#{item.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Title"/>
                </f:facet>
                <h:outputText value="#{item.title}"/>
            </h:column>
             <h:column>
                <f:facet name="header">
                    <h:outputText value="Author"/>
                </f:facet>
                <h:outputText value="#{item.author}"/>
            </h:column>
             <h:column>
                <f:facet name="header">
                    <h:outputText value="Publisher"/>
                </f:facet>
                <h:outputText value="#{item.publisher}"/>
            </h:column>
             <h:column>
                <f:facet name="header">
                    <h:outputText value="Year Published"/>
                </f:facet>
                <h:outputText value="#{item.yearPublished}"/>
            </h:column>
             <h:column>
                <f:facet name="header">
                    <h:outputText value="Format"/>
                </f:facet>
                <h:outputText value="#{item.format}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Status"/>
                </f:facet>
                <h:outputText value="#{item.status}"/>
            </h:column>
             <h:column>
                <f:facet name="header">
                    <h:outputText value="Action"/>
                    
                </f:facet>
                 
             </h:column>
        </h:dataTable>
        <h:outputText id="searchError" rendered="#{jSFLibraryManagerBean.displaySearchError()}" value="#{jSFLibraryManagerBean.errorMessage}"/>
       <h:form>
           <h:commandButton value="Check-In" action="#{jSFLibraryManagerBean.checkIn()}" rendered="#{jSFLibraryManagerBean.toggleResults()}"/>
           <h:commandButton value="Check-Out" action="#{jSFLibraryManagerBean.checkOut()}" rendered="#{jSFLibraryManagerBean.toggleResults()}" />
                 </h:form>
          <h:form>
          <h:commandButton action="#{downloadManagerBean.downLoad()}" value="Download Log"/>
          </h:form>
    </h:body>
    
</html>

